package ysutils

const (
	TypeInt     = "int"
	TypeInt8    = "int8"
	TypeInt16   = "int16"
	TypeInt32   = "int32"
	TypeInt64   = "int64"
	TypeUint    = "uint"
	TypeUint8   = "uint8"
	TypeUint16  = "uint16"
	TypeUint32  = "uint32"
	TypeUint64  = "uint64"
	TypeFloat32 = "float32"
	TypeFloat64 = "float64"
	TypeBool    = "bool"
	TypeString  = "string"
)

// IsBaseType 判断字符串 <t> 是不是 Go 语言的基本数据类型
func IsBaseType(t string) bool {
	return IsTypeInteger(t) ||
		IsTypeUnsignedInteger(t) ||
		IsTypeFloatingPoint(t) ||
		IsTypeBool(t) ||
		IsTypeString(t)
}

func IsTypeNumber(t string) bool {
	return IsTypeInteger(t) || IsTypeFloatingPoint(t) || IsTypeUnsignedInteger(t)
}

func IsTypeInteger(t string) bool {
	return t == TypeInt || t == TypeInt8 || t == TypeInt16 || t == TypeInt32 || t == TypeInt64
}

func IsTypeUnsignedInteger(t string) bool {
	return t == TypeUint ||
		t == TypeUint8 ||
		t == TypeUint16 ||
		t == TypeUint32 ||
		t == TypeUint64
}

func IsTypeFloatingPoint(t string) bool {
	return t == TypeFloat32 ||
		t == TypeFloat64
}

func IsTypeBool(t string) bool {
	return t == TypeBool
}

func IsTypeString(t string) bool {
	return t == TypeString
}
